<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="xz">
    <button class="xzan">新增</button>
    <input type="text" class="inp">
    <div class="box"></div>
</body>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script>
    const box=document.querySelector('.box')
    const xz=document.querySelector('.xz')
    const xzan=document.querySelector('.xzan')
    const inp=document.querySelector('.inp')
    //新增
    xzan.addEventListener('click',()=>{
        axios.post('http://127.0.0.1:7001/order').then(res=>{})
    })
    const init=()=>{
        axios.get('http://127.0.0.1:7001/order').then(res=>{
            res.data.file.forEach(item => {
                // console.log(item);
                const div=document.createElement('div')
                const text=document.createTextNode(item.title+'---')
                const sc=document.createElement('button')
                const bj=document.createElement('button')
                sc.innerHTML='删除'
                bj.innerHTML='编辑'
                div.appendChild(text)
                div.appendChild(sc)
                div.appendChild(bj)
                box.appendChild(div)
                
                //修改
                bj.addEventListener('click',()=>{
                    axios.put('http://127.0.0.1:7001/order').then(res=>{})
                })

                //删除
                sc.addEventListener('click',()=>{
                    axios.delete('http://127.0.0.1:7001/order').then(res=>{})
                })
            });
        })
    }
    init()
</script>
</html>